<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 *订单管理
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$return=array();
$return['task_status']=$this->log_status;
$tabs=array(
	array('op'=>'list','title'=>'全部记录'),
); 
if($_RQ['op']=='list'){
	$return['params']=array();
	$params=array('uniacid'=>$_SESSION['uniacid']);
	if(isset($_RQ['type']) && $_RQ['type']!=100){
		$params['type']=intval($_RQ['type']);
		$return['params']['type']=intval($_RQ['type']);
	}
	if(isset($_RQ['workerid'])){
		$params['workerid']=intval($_RQ['workerid']);
		$return['params']['workerid']=intval($_RQ['workerid']);
	}
	$pindex = max(1, intval($_RQ['page']));
	if($_RQ['psize']){
		$_SESSION['psize']=$_RQ['psize'];
	}
	$psize = $_SESSION['psize']?:10;
	$list=pdo_getslice('jy_scrmtask_log',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as $k=>&$item){
			$task=pdo_get('jy_scrmtask_list',array('id'=>$item['tid']));
			$item['title']=$task['title'];
			$item['url']=custom_url('jy_scrmtask/log_item//id='.$item['id'],true);
			if($item['status']!=2){
				if($item['type']==3){
					$item['isusernum']=$this->model('model')->siyu_uplog($item);
				}
			}
		}
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','tip'=>'
			[温馨提示]：加好友数据--完成数的更新--需要先【同步客户】，不然数据不准确，已完成的任务，完成数不再追加！
		',
		'total'=>$total,'psize'=>$psize,'edit'=>false,'del_one'=>false,'delall'=>false,'list'=>array(
			array('name'=>'workerid','title'=>'成员','type'=>'select','options'=>'workers','option_title'=>'name'),
			array('name'=>'title','title'=>'任务名称','type'=>'string'),
			array('name'=>'usernum','title'=>'任务数','type'=>'string'),
			array('name'=>'isusernum','title'=>'完成数','type'=>'string'),
			array('name'=>'type','title'=>'任务类型','type'=>'radio','options'=>'task_type'),
			array('name'=>'status','title'=>'任务状态','type'=>'radio','options'=>'task_status'),
			array('name'=>'url','title'=>'任务链接','type'=>'copy'),
			array('name'=>'url','title'=>'任务链接','type'=>'ewm'),
			array('name'=>'end_time','title'=>'结束时间','type'=>'time'),
			array('name'=>'createtime','title'=>'创建时间','type'=>'time'),
		)),
		'search'=>array(
			array('name'=>'type','width'=>15,'title'=>'任务类型','type'=>'radio','options'=>'task_type'),
			array('name'=>'status','width'=>15,'title'=>'任务状态','type'=>'radio','options'=>'task_status'),
			array('type'=>'choose','width'=>15,'title'=>'部门成员','name'=>'workerid','action'=>'jy_scrm/worker.get_worker/'),
		),
	);
	if($_RQ['type']!=3){
		unset($htmls['list']['list'][2]);
		unset($htmls['list']['list'][3]);
	}
	$return['task_type']=$this->task_type;
	$return['workers']=pdo_getall('jy_scrm_worker',array('uniacid'=>$_SESSION['uniacid']),array('id','name'),'id');
	$return['htmls']=$htmls;	
	exi($return);
}
